'use strict';
const Service = require('egg').Service;
class NewsService extends Service {

  // 查询列表
  async list(params) {
    const { serverUrl, port1, port2 } = this.config.news;
    const data = await this.ctx.service.login.request(`${serverUrl}:${port2}/ppdk/sh/list`, {
      method: 'GET',
      contentType: 'text/html',
      data: params,
      dataType: 'json',
    });
    return data;
  }

  async list_tg(params) {
    const { serverUrl, port1, port2 } = this.config.news;
    const data = await this.ctx.service.login.request(`${serverUrl}:${port2}/zpdk/tj`, {
      method: 'GET',
      contentType: 'text/html',
      data: params,
      dataType: 'json',
    });
    return data;
  }

  // 查看
  async chakan1(params) {
    const { serverUrl, port1, port2 } = this.config.news;
    const data = await this.ctx.service.login.request(`${serverUrl}:${port2}/zpdk/tjxq`, {
      method: 'GET',
      contentType: 'text/html',
      data: params,
      dataType: 'json',
    });
    // console.log("----------------------123")
    // console.log(params.sprdm)
    return data;
  }




  async select_jgdm(params) {
    const { serverUrl, port1, port2 } = this.config.news;
    const data = await this.ctx.service.login.request(`${serverUrl}:${port2}/zpdk/swjg/get`, {
      method: 'GET',
      contentType: 'text/html',
      data: params,
      dataType: 'json',
    });
    // console.log('----------------pp');
    // console.log(data);
    return data;
  }

  // 查看
  async detaildate(params) {
    const { serverUrl, port1, port2 } = this.config.news;
    const data = await this.ctx.service.login.request(`${serverUrl}:${port2}/ppdk/sh/${params.id}/get`, {
      method: 'GET',
      contentType: 'text/html',
      data: params,
      dataType: 'json',
    });

    return data;
  }

  // 查看
  async detaildate99(params) {
    const { serverUrl, port1, port2 } = this.config.news;
    const data = await this.ctx.service.login.request(`${serverUrl}:${port2}/ppdk/sh/${params.id}/get`, {
      method: 'GET',
      contentType: 'text/html',
      data: params,
      dataType: 'json',
    });
    // console.log("----------------------")
    // console.log(params.id)
    return data;
  }

  // 新增
  async adddata(params) {
    const { serverUrl, port1, port2 } = this.config.news;
    const data = await this.ctx.service.login.request(`${serverUrl}:${port2}/zzzd_pzxx/insert`, {
      method: 'GET',
      contentType: 'text/html',
      data: params,
      dataType: 'json',
    });
    return data;
  }

  // 修改
  async update(params) {
    const { serverUrl, port1, port2 } = this.config.news;
    const data = await this.ctx.service.login.request(`${serverUrl}:${port2}/ppdk/sh/${params.id}/shfp`, {
      method: 'GET',
      contentType: 'text/html',
      data: params,
      dataType: 'json',
    });
    return data;
  }

  // 删除
  async delete(params) {
    const { serverUrl, port1, port2 } = this.config.news;
    const data = await this.ctx.service.login.request(`${serverUrl}:${port2}/zzzd_pzxx/delete`, {
      method: 'GET',
      contentType: 'text/html',
      data: params,
      dataType: 'json',
    });
    return data;
  }
}

module.exports = NewsService;
